import type { RoutesType } from './types'
import BasicSkillHome from '@/basicskills/BasicSkillHome.vue'

const prefix = '/basic'
/**
 * 使用一个闭包，只初始化一次routes(添加前缀)
 */
const getRoutes = (function (prefixArg: string) {
  let routes: RoutesType = {
    '/home': BasicSkillHome
  }

  let newRoutes: RoutesType = {}
  for (let key in routes) {
    if (routes.hasOwnProperty(key)) {
      newRoutes[`${prefixArg}${key}`] = routes[key]
    }
  }

  routes = newRoutes
  return () => routes
})(prefix)

const routes = getRoutes()

export default routes
